{{define "content"}}
{{$pageTitle:="用户列表"}}
<style>
    .title{
        color: #8b4902;
    }
</style>
<div class="head">
    <div class="title">
        {{$pageTitle}}
    </div>
</div>
<div class="orderlist m10 myorder">
    <form action="/admin/user/index/" method="post" id="searchForm">
        <div class="search">
            <label>姓名</label><input type="text" class="text midtext" style="width:150px;" name="name" value="{{.name}}" />
            <label>创建时间</label><input type="text" class="text midtext" style="width:150px;" name="createTimeFrom" value="{{.createTimeFrom}}" /> To <input type="text" class="text midtext" style="width:150px;" name="createTimeTo" value="{{.createTimeTo}}" />
            <input type="submit" class="btn1" value="搜索" accesskey="S" />
        </div>
    </form>
    <div class="tab_cont">
        <div class="List">
            {{template "_list" .}}
        </div>
    </div>
</div>
{{end}}

{{define "_list"}}
<div>
    <a href="/admin/user/edit/?id=0" class="btn1" target="_blank">新增</a>
</div>
<table class="mytable" width="50%">
    <tr>
        <th style="width:3%">Id</th>
        <th style="width:10%">用户名</th>
        <th style="width:3%">角色</th>
        <th style="width:8%">操作</th>
    </tr>
    {{range $index, $item :=.list}}
    <tr data-id="{{$item.Id}}">
        <td>{{$item.Id}}</td>
        <td>{{$item.Name}}</td>
        <td>{{$.T.P $item.CreateTime}}</td>
        <td>
            <a href="/admin/user/edit/?id={{$item.Id}}" class="btn1" target="_blank">编辑</a>
            <a href="javascript:del({{$item.Id}})" class="del">删除</a>
        </td>
    </tr>
    {{end}}
</table>
<div class="total pt10">
    {{template "pager" .}}
</div>
<script type="text/javascript">
    function del(id) {
        if(!confirm("请确认用户不再使用,删除后不可恢复？"))
        {
            return;
        }
        $.ajax({
            url: '/user/del/',
            type: "post",
            data: {
                id: id
            },
            success: function (data) {
                if (data.code > 0) {
                    window.location.reload();
                }
                else {
                    alert(data.message);
                }
            }
        });
    }
</script>
{{end}}

{{define "user/index.html"}}
{{template "layout.html" .}}
{{end}}